package com.wisezone.java1902.d14_map;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Map.Entry;
import java.util.Set;

public class TestHashMap {
	public static void test1() {
		Map<String,String> map = new HashMap<>();
		map.put("key1", "java语言");
		map.put("key2", "c语言");
		map.put("key3", "python语言");
		
		String value = map.get("key2");
		System.out.println(value);
		
	}
	
	public static void test2() {
		Student stu1 = new Student("小明",1001);
		Student stu2 = new Student("小丽",1002);
		Student stu3 = new Student("张三",1003);
		Student stu4 = new Student("王二",1004);
		
		Map<Integer,Student> studentMaps = new HashMap<>();
		
		studentMaps.put(1001,stu1);
		studentMaps.put(1002,stu2);
		studentMaps.put(1003,stu3);
		studentMaps.put(1004,stu4);
		
//		Set<Integer> keySets = studentMaps.keySet();
//		for (Integer key : keySets) {
//			System.out.println(studentMaps.get(key));
//		}
		
		Set<Map.Entry<Integer, Student>> studentEntrys =  studentMaps.entrySet();
		for (Entry<Integer, Student> entry : studentEntrys) {
			System.out.println(entry.getKey() + " "+entry.getValue());
		}
		
	}
	
	public static void test3() {
		Properties propert = new Properties();
		propert.setProperty("username", "root");
		propert.setProperty("password", "321");
		
		String user = propert.getProperty("username");
		System.out.println(user);
	}
	
	public static void main(String[] args) {
		test3();
	}

}
